package com.itheima.dubbo.mysql.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.itheima.commons.model.domain.HuanxinUser;
import com.itheima.dubbo.interfaces.HuanxinUserApi;
import com.itheima.dubbo.mysql.mapper.HuanXinUserMapper;
import org.springframework.beans.factory.annotation.Autowired;


@Service
public class HuanxinUserApiImpl implements HuanxinUserApi {

    @Autowired
    private HuanXinUserMapper hxUserMapper;

    @Override
    public HuanxinUser queryHuanXinUserByUserId(Long userId) {
        return hxUserMapper.selectOne(Wrappers.lambdaQuery(HuanxinUser.class)
                .eq(HuanxinUser::getUserId, userId));
    }

    @Override
    public void saveHuanxinUser(HuanxinUser hxuser) {
        hxUserMapper.insert(hxuser);
    }

    @Override
    public HuanxinUser queryHuanXinUserByUserUserName(String hxUsername) {
        return hxUserMapper.selectOne(Wrappers.lambdaQuery(HuanxinUser.class)
                .eq(HuanxinUser::getNickname, hxUsername));
    }
}
